Data Science for Business Professionals by Probyto Data Science and Consulting Pvt. Ltd

Data Science for Business Professionals by Probyto Data Science and Consulting Pvt. Ltd

Author:Probyto Data Science and Consulting Pvt. Ltd. [Probyto Data Science and Consulting Pvt. Ltd.]
Language: eng
Format: epub
ISBN: 9789389423280
Publisher: BPB Publications
Published: 2020-05-15T00:00:00+00:00


#Import the library

import sys

#Print the arguments passed to the script

argument_1 = sys.argv[1]

argument_2 = sys.argv[2]

print("
The First argument passed is ", argument_1, "

The Second argument passed is ", argument_2)

Now, we will call the above script with two arguments; let's say Hello and 5. The script should catch the arguments and make them available as two arguments values:

!Python Code_9_3_Example_sys_args.py Hello 5

The First argument passed is Hello

The Second argument passed is 5

We now will modify our script of the data pipeline to see if it can take the limit as command line arguments and fetch as many records as required by the user. The following script is the modified script to show the use of argv in data pipeline arguments. Save the script as Code_9_4_Command_line_data-pipeline.py and run it from console to see how the results differ for two different arguments:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.